﻿package Map {
	import Component.Blaze;
	import Component.Map;
	
	public class BlazePool {

		private var blazes_available:Vector.<Blaze>;
		private var map:Map;

		public function BlazePool(map:Map) {
			this.map = map;
			blazes_available = new Vector.<Blaze>();
		}
		
		public function grab():Blaze {
			var blaze:Blaze;
			if(blazes_available.length > 0) blaze = blazes_available.pop();
			else {
				blaze = new Blaze();
				map.attach(blaze);
			}
			return blaze;
		}
		
		public function release(blaze:Blaze) {
			blaze.visible = false;
			blazes_available.push(blaze);
		}

	}
	
}
